//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows.Media;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public abstract class FillModeProperties : IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            ReadXmlCore(context);
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            WriteXmlCore(context);
        }

        #endregion

        internal static FillModeProperties ReadOptionalFillModeProperties(ReadContext ccc)
        {
            switch (ccc.ReaderLocalName)
            {
                case "tile":
                    TileModeProperties t = new TileModeProperties();
                    t.ReadXmlCore(ccc);
                    return t;
                case "stretch":
                    StretchModeProperties s = new StretchModeProperties();
                    s.ReadXmlCore(ccc);
                    return s;
                case null:
                    return null;
                default:
                    throw new NotSupportedException(ccc.ReaderLocalName);
            }
        }

        internal abstract void ReadXmlCore(ReadContext context);

        internal abstract void WriteXmlCore(WriteContext context);

        public abstract void Apply(ImageBrush brush);
    }
}